package com.pipe.protocol.query;

import com.pipe.util.MyBytebufUtil;
import com.pipe.util.MysqlProtocolUtil;
import io.netty.buffer.ByteBuf;

import java.util.LinkedList;
import java.util.List;

/**
 * @author Kiven
 */
public class ResultsetRowPacakge {
    private List<String> value;

    public ResultsetRowPacakge(List<String> value) {
        this.value = value;
    }

    public static ResultsetRowPacakge build(ByteBuf byteBuf) {
        List<String> value = new LinkedList<>();
        for (;byteBuf.isReadable();){
            value.add(MysqlProtocolUtil.readRowLenencStringFromBytebuf(byteBuf));
        }
        return new ResultsetRowPacakge(value);
    }

    public List<String> getValue() {
        return value;
    }

    @Override
    public String toString() {
        return "ResultsetRowPacakge{" +
                "value=" + value +
                '}';
    }
}